﻿@page
@model Emprise.Web.Areas.Admin.Pages.Player.IndexModel
@{
    ViewData["Title"] = "玩家管理";
    ViewData["MenuGroup"] = MenuGroupEnum.Game;
}

@section CssJs {
    <link rel="stylesheet" href="~/admin/css/amazeui.switch.css" />
}

<div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">玩家管理</strong> / <small>玩家列表</small></div>
</div>

<div class="am-g">
    <div class="am-u-md-6 am-cf">
        <div class="am-fl am-cf">
            <div class="am-btn-toolbar am-fl">


            </div>
        </div>
    </div>
    <div class="am-u-md-3 am-cf">
        <form class="am-form">
            <div class="am-fr">
                <div class="am-input-group am-input-group-sm">
                    <input type="text" class="am-form-field" asp-for="Keyword">
                    <span class="am-input-group-btn">
                        <button class="am-btn am-btn-default" type="submit">搜索</button>
                    </span>

                </div>
            </div>
        </form>
    </div>
</div>

<div class="am-g">
    <div class="am-u-sm-12">
        <form class="am-form">
            <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                    <tr>
                        <th style="width:60px">ID</th>
                        <th style="width:150px">名称</th>
                        <th style="width:120px">创建时间</th>
                        <th style="width:120px">最后登录时间</th>
                        <th style="width:60px">性别</th>
                        <th style="width:60px">年龄</th>
                        <th style="width:60px">等级</th>
                        <th style="width:60px">状态</th>
                        <th style="width:60px">房间</th>
                        <th>属性</th>
                        <th style="width:120px">气血</th>
                        <th style="width:120px">内力</th>
                        <th style="width:120px">攻防</th>
                        <th style="width:120px">金钱</th>
                        <th style="width:240px">操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var player in Model.Paging.Data)
                    {


                    <tr>
                        <td>@(player.Id)</td>
                        <td><a asp-page="./Edit" asp-route-id="@player.Id">@(player.Name)</a></td>
                        <td title="@(player.CreateDate)">@(player.CreateDate.ToFriendlyTime())</td>
                        <td title="@(player.LastDate)">@(player.LastDate.ToFriendlyTime())</td>
                        <td>@(player.Gender)</td>
                        <td>@(player.Age/12)</td>
                        <td>@(player.Level)</td>
                        <td>@(player.Status)</td>
                        <td>@(player.RoomId)</td>
                        <td>@(player.Str)+@(player.StrAdd)/@(player.Con)+@(player.ConAdd)/@(player.Int)+@(player.IntAdd)/@(player.Dex)+@(player.DexAdd)</td>
                        <td>@(player.Hp)/@(player.MaxHp)</td>
                        <td>@(player.Mp)/@(player.MaxMp)/@(player.LimitMp)</td>
                        <td>@(player.Atk)/@(player.Def)</td>
                        <td>@(player.Money)</td>
                        <td>
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-xs">
                                    <a asp-page="./User" asp-route-id="@player.Id" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 所属用户</a>
                                    <a asp-page="./Edit" asp-route-id="@player.Id" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 编辑</a>

                                    <a asp-page="./Delete" asp-route-id="@player.Id" class="am-btn am-btn-default am-btn-xs am-text-danger"><span class="am-icon-trash-o"></span> 删除</a>
                                </div>
                            </div>
                        </td>
                    </tr>
                    }
                </tbody>
            </table>
            <div class="am-cf">
                共 @(Model.Paging.Count) 条记录
                <div class="am-fr">
                    <ul class="am-pagination">
                        <li><a asp-route-pageIndex="1" asp-route-keyword="@(Model.Keyword)">«</a></li>

                        @for (var i = 0; i < Model.Paging.PageCount; i++)
                        {
                            if (Model.Paging.PageIndex == i + 1)
                            {
                                <li class="am-active"><a href="javascript:;">@(i + 1)</a></li>
                            }
                            else
                            {
                                <li><a asp-route-pageIndex="@(i+1)" asp-route-keyword="@(Model.Keyword)">@(i + 1)</a></li>
                            }
                        }

                        <li><a asp-route-pageIndex="@(Model.Paging.PageCount)" asp-route-keyword="@(Model.Keyword)">»</a></li>
                    </ul>
                </div>
            </div>
            <hr />
            <p>注：.....</p>
        </form>
    </div>

</div>


@Html.AntiForgeryToken()

@section Scripts {

    <script src="~/admin/js/amazeui.switch.min.js"></script>
    <script src="~/admin/js/axios.min.js"></script>

    <script type="text/javascript">
        $(function () {
            $('[type="checkbox"]').bootstrapSwitch();


            $('[type="checkbox"]').on('switchChange.bootstrapSwitch', function (event, state) {
                                    var sId = $(this).attr("sId")*1;
                                    axios.post('@(Url.Page("/Npc/Index"))', {
                                        sId: sId,
                    isEnable: state
                                    },
                    {
                                        headers: {
                                            "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val()
                                        }
                                    })
                    .then(function (response) {
                                        console.log(response);
                                    })
                    .catch(function (error) {
                                        console.log(error);
                                    });
            });
        });
    </script>
}